package com.nxn.core.utils;

import javax.servlet.ServletContextEvent;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.nxn.core.service.DataLoaderService;

public class CacheListener extends ContextLoaderListener{
	public static final String xmlFileName = "/web-assets.xml";
	
	private DataLoaderService dataLoader;
	
	@Override
	public void contextInitialized(ServletContextEvent event) {
		super.contextInitialized(event);
		
		ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());  
        //获取bean
		dataLoader = (DataLoaderService) applicationContext.getBean("dataLoaderService");  
		
		dataLoader.initWebAssets(xmlFileName);
	}
}